class P10050 {

	public static void main(String[] args) {
		int cases = Integer.parseInt(readLn());
		for (int k = 0; k < cases; k++) {
			int days = Integer.parseInt(readLn());
			int parties = Integer.parseInt(readLn());
			process(days, parties);
		}
	}

	private static void process(int days, int parties) {
		int[] party = new int[parties];
		for (int k = 0; k < parties; k++) {
			party[k] = Integer.parseInt(readLn());
		}

		boolean[] day = new boolean[days + 1];

		for (int k = 0; k < parties; k++) {
			try {
				for (int j = 1;; j++) {
					day[j * party[k]] = true;
				}
			} catch (Exception e) {

			}
		}

//		for (int k = 1; k <= days; k++) {
//			System.out.println(k + " " + day[k]);
//		}

		int counter = 0;
//		boolean[] mask = { true, true, true, true, true, true, false, false };
		int x = 1;
		for (int k = 1; k <= days; k++) {
			if (!(x == 6 || x == 7)) {
				if (day[k]) {
					counter++;
				}
			}
			x++;
			if (x== 8) {
				x = 1;
			}
		}
		System.out.println(counter);
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}